GET /api/vitals: slim scale + capacity endpoint#1094
Merged
Conversation
7adcc71 to
e958724
Compare
e958724 to
30068ca
Compare
05862dd to
f82f48d
Compare
82fcaa6 to
197e6be
Compare
9c9f0b2 to
fdd7790
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit fdd7790. Configure here.
fdd7790 to
fd71713
Compare
Purpose-built for Radar Cloud's fleet fan-out, which previously projected this corner out of the full /api/dashboard payload and discarded the rest. Returns node/pod phase counts (namespace-scoped to the caller's access), CPU/memory MetricSummary, and the metrics-server-availability flag. Completeness is typed, never stringly: accessRestricted, pending and restricted (k8score ResourceType values, filtered to vitals-relevant kinds), and a derived complete flag — including a "nodes" restricted sentinel the dashboard never had (consumers previously inferred node RBAC blindness from zero totals). Metrics-server usage is memoized for 15s per RBAC scope so fleet polling doesn't turn every request into a live probe; requests/capacity stay informer-derived.
fd71713 to
22b2a1a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
New endpoint returning per-cluster scale and capacity — node/pod phase counts, CPU/memory usage+requests vs allocatable, metrics-server availability — without the home-page payload. Purpose-built for Radar Cloud's fleet fan-out (which previously fetched the full
/api/dashboardper cluster and discarded ~90% of it), equally usable by any consumer that wants vitals without the kitchen sink.What changed
GET /api/vitals(internal/server/vitals.go), mounted beside/api/dashboardin the authed API group. Pod counts are namespace-scoped to the caller's access; node counts gate on the caller's own node RBAC like the dashboard does.completeness.{accessRestricted, pending[], restricted[], complete}— sentinel lists carryk8scoreResourceType values filtered to vitals-relevant kinds, andcompleteis derived server-side. Includes a"nodes"restricted sentinel the dashboard never had (consumers previously had to infer node RBAC blindness from zero totals). Metrics availability is deliberately not part of completeness — it's a capability, reported separately.omitempty— fleet consumers get fixed fields, not fields that vanish at zero.Testing
go test ./internal/server/green, including two new tests: happy path against the smoke fixture (counts, completeness, no false metrics claim) and node-RBAC-denial surfacingrestricted: ["nodes"]+complete: falsethrough the real permission-cache gate.Part of the endpoint rework for cloud; the hub-side switch of its vitals fan-out to this endpoint lands separately.
Note
Medium Risk
New authenticated API surface with nuanced RBAC and namespace scoping; incorrect gates could leak pod/node aggregates, though behavior is covered by new tests and mirrors dashboard patterns.
Overview
Adds
GET /api/vitals, a lightweight alternative to the full dashboard: node/pod phase counts, CPU/memory capacity vs requests vs live usage,metricsServerAvailable, and a typedcompletenessblock (accessRestricted,pending,restricted, derivedcomplete) so fleet consumers do not infer RBAC blindness from zeros (e.g.Nodeinrestricted).Shared cluster-metrics plumbing moves into
node_metrics.go(fetchNodeUsage,listPodsScoped,computeCapacityRequests); the dashboard metrics path now calls those helpers instead of inlined logic. Only the metrics-server probe is memoized (~15s per kube-context + user,singleflighton bursts); capacity/requests stay informer-fresh. The memo is cleared infinalizePostContextSwitchalongside other per-cluster state.Pod data is gated on explicit list pods RBAC (not just namespace visibility); node counts and cluster capacity sit behind list nodes, matching dashboard semantics. Pod phase fields use a stable JSON shape (no
omitemptyon zeros).golang.org/x/syncis a direct dependency forsingleflight.Reviewed by Cursor Bugbot for commit 22b2a1a. Bugbot is set up for automated code reviews on this repo. Configure here.